<?php echo $this->element("admin_header"); ?>
<div class="posts index">
<h2><?php __('Posts');?></h2>
<table cellpadding="0" cellspacing="0">
<tr>
	<th>Category</th>
	<th><?php echo $paginator->sort('title');?></th>
	<th><?php echo $paginator->sort('body');?></th>
	<th><?php echo $paginator->sort('date');?></th>
	<th><?php echo $paginator->sort('published');?></th>
	<th><?php echo $paginator->sort('modified');?></th>
	<th><?php echo $paginator->sort('views');?></th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($posts as $post):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			<?php foreach($post['Category'] as $category):?>
			<?php echo $html->link($category['title'], array('controller'=>'categories','action'=>'view', $category['id'])); ?>
			<?php endforeach; ?>
		</td>
		<td>
			<?php echo $html->link($post['Post']['title'], array('action'=>'view', $post['Post']['slug'],'admin' => false), array('target'=>'_blank') ); ?>
		</td> 
		<td class="left">
			<?php echo $text->truncate(strip_tags($post['Post']['body']), 100); ?>
		</td>
		<td>
			<?php echo $time->niceShort($post['Post']['date']); ?>
		</td>
		<td>
			<?php echo $post['Post']['published']; ?>
		</td>
		<td>
			<?php echo $time->nice($post['Post']['modified']); ?>
		</td>
			<td>
				<?php echo $post['Post']['views'] ?>
			</td>
		<td class="actions">
			<?php echo $html->link(__('View', true), array('admin'=>false,'action'=>'view',  $post['Post']['id'])); ?>
			<?php echo $html->link(__('Edit', true), array('action'=>'edit', $post['Post']['id'])); ?>
			<?php echo $html->link(__('Delete', true), array('action'=>'delete', $post['Post']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $post['Post']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
</div>
<?php echo $this->element("paging"); ?>
